<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    
<head>    
    <script type="text/javascript" src="http://csdnimg.cn/pubfooter/js/tracking.js" charset="utf-8"></script>  

    <script type="text/javascript">
        var protocol = window.location.protocol;
        document.write('<script type="text/javascript" src="' + protocol + '//csdnimg.cn/pubfooter/js/repoAddr2.js?v=' + Math.random() + '"></' + 'script>');
    </script>


    <script id="allmobilize" charset="utf-8" src="http://a.yunshipei.com/46aae4d1e2371e4aa769798941cef698/allmobilize.min.js"></script>
 <meta http-equiv="Cache-Control" content="no-siteapp" /><link rel="alternate" media="handheld" href="#" />

    <title>如何理解stdlib.h里的_countof()宏 - yuanmanzheng的专栏
        - 博客频道 - CSDN.NET</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="在stdlib.h里有一个宏_countof，如下：extern C++{template char (*__countof_helper(UNALIGNED _CountofType (&amp;_Array)[_SizeOfArray]))[_SizeOfArray];#define _countof(_Array) sizeof(*__countof_helper(_Array))}" />
    <script src="http://static.blog.csdn.net/scripts/jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="http://static.blog.csdn.net/scripts/ad.js?v=1.1"></script>
        <!--new top-->
               <link rel="stylesheet" href="http://static.csdn.net/public/common/toolbar/css/index.css">        <!--new top-->

    <link rel="Stylesheet" type="text/css" href="http://static.blog.csdn.net/skin/default/css/style.css?v=1.1" />
    <link id="RSSLink" title="RSS" type="application/rss+xml" rel="alternate" href="/yuanmanzheng/rss/list" />
    <link rel="shortcut icon" href="http://csdnimg.cn/public/favicon.ico" />
    <link type="text/css" rel="stylesheet" href="http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/default.css" />
 


</head>
<body>
    
   
      <!--new top-->
    <script id="toolbar-tpl-scriptId" fixed="true" prod="blog" skin="black" src="http://static.csdn.net/public/common/toolbar/js/html.js" type="text/javascript"></script>
     <!--new top-->
    <div id="container">
        <div id="header">
    <div class="header">
        <div id="blog_title">
            <h2>
                <a href="http://blog.csdn.net/yuanmanzheng">yuanmanzheng的专栏</a></h2>
            <h3></h3>
            <div class="clear">
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
</div>
<div id="navigator">
    <div class="navigator_bg">
    </div>
    <div class="navigator">
        <ul>
                <li id="btnContents"><a href="http://blog.csdn.net/yuanmanzheng?viewmode=contents"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_mulu'])">
                    <img src="http://static.blog.csdn.net/images/ico_list.gif">目录视图</span></a></li>
                <li id="btnView"><a href="http://blog.csdn.net/yuanmanzheng?viewmode=list"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_zhaiyao'])">
                    <img src="http://static.blog.csdn.net/images/ico_summary.gif">摘要视图</span></a></li>
                <li id="btnRss"><a href="http://blog.csdn.net/yuanmanzheng/rss/list"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_RSS'])">
                    <img src="http://static.blog.csdn.net/images/ico_rss.gif">订阅</span></a></li>                

            </ul>
    </div>
</div>
<script type="text/javascript">
    var username = "yuanmanzheng";
    var _blogger = username;
    var blog_address = "http://blog.csdn.net/yuanmanzheng";
    var static_host = "http://static.blog.csdn.net";
    var currentUserName = "cnheike";  
</script>

        <div id="body">
            <div id="main">
                <div class="main">
                        <div class="ad_class">
<div class="notice tracking-ad" data-mod='popu_3' > 


<a href="http://edu.csdn.net/course/detail/330">
<font color=blue>从零开始掌握iOS8开发技术（Swift版）</font></a>

&nbsp;&nbsp;&nbsp;&nbsp;

<a href="http://blog.csdn.net/blogdevteam/article/details/41842837">
<font color=red>《京东技术解密》有奖试读获奖名单公布
</font></a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="http://edu.csdn.net/course/detail/162">
<font color=blue>Qt基础与Qt on Android入门
</font></a>
&nbsp;&nbsp;&nbsp;&nbsp;

<a href="http://blog.csdn.net/blogdevteam/article/details/42172979">
<font color=red>“我的2014”年度征文活动火爆开启
</font></a>


</div>                        </div>
                        

  
<link href="http://static.blog.csdn.net/css/comment1.css" type="text/css" rel="stylesheet" />
<link href="http://static.blog.csdn.net/css/style1.css" type="text/css" rel="stylesheet" />
<script language='JavaScript' type='text/javascript' src='http://download.csdn.net/js/jquery.cookie.js'></script>
<script type="text/javascript" src="http://csdnimg.cn/rabbit/search-service/main.js"></script>
  <script type="text/ecmascript">
      window.quickReplyflag = true;
    </script>
<div id="article_details" class="details">
    <div class="article_title">   
         <span class="ico ico_type_Original"></span>


    <h1>
        <span class="link_title"><a href="/yuanmanzheng/article/details/5472967">
        如何理解stdlib.h里的_countof()宏
        </a></span>
    </h1>
</div>

    <div class="article_manage">
    <span class="link_postdate">2010-04-11 16:13</span>
    <span class="link_view" title="阅读次数">2867人阅读</span>
    <span class="link_comments" title="评论次数"><a href="#comments" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_pinglun'])">评论</a>(8)</span>
    <span class="link_collect"><a href="javascript:void(0);" onclick="javascript:_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shoucang']);collectArticle('如何理解stdlib.h里的_countof()宏','5472967');return false;" title="收藏">收藏</a></span>
    <span class="link_report"><a href="#report"  onclick="javascript:_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_jubao']);report(5472967,2);return false;" title="举报">举报</a></span>
    
</div>
<div class="tag2box"><a href='http://www.csdn.net/tag/fun' target=_blank onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_tag']);">fun</a><a href='http://www.csdn.net/tag/reference' target=_blank onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_tag']);">reference</a><a href='http://www.csdn.net/tag/%e7%bc%96%e8%af%91%e5%99%a8' target=_blank onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_tag']);">编译器</a><a href='http://www.csdn.net/tag/templates' target=_blank onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_tag']);">templates</a><a href='http://www.csdn.net/tag/pointers' target=_blank onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_tag']);">pointers</a><a href='http://www.csdn.net/tag/vector' target=_blank onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_tag']);">vector</a></div>

  
    
<div id="article_content" class="article_content">
<p>在stdlib.h里有一个宏_countof，如下：</p>
<p>extern "C++"<br />{<br /><span style="color: #0000ff;">template &lt;typename _CountofType, size_t _SizeOfArray&gt;<br />char (*__countof_helper(UNALIGNED _CountofType (&amp;_Array)[_SizeOfArray]))[_SizeOfArray];</span></p>
<p><br />#define <span style="color: #ff0000;">_countof</span>(_Array) sizeof(<span style="color: #ff0000;">*</span>__countof_helper(_Array))<br />}</p>
<p>&nbsp;</p>
<p>这个宏的作用就是得到一个数组元素的大小。</p>
<p>&nbsp;</p>
<p>如下使用：</p>
<p>#include &lt;stdlib.h&gt;</p>
<p>int main()</p>
<p>{</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int a[5];</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ......</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int&nbsp;arraySize =&nbsp;_countof(a); //得到数组a的大小&nbsp;</p>
<p>}</p>
<p>////////////////////////////////////////////////////////////////////////////////////////////////</p>
<p>&nbsp;</p>
<p>这个宏使用了一些大家平时都比较少用到的语法。所以理解起来，一下子不是很明白。</p>
<p>所以这里简单说说，如何理解它吧。<br /><br />为了说明方便，改写如下：<br />template &lt;typename <span style="color: #ff0000;">T</span>, size_t <span style="color: #ff0000;">N</span>&gt;<br /><span style="color: #00ff00;">char (*</span> <span style="color: #ff0000;">__countof_helper</span> ( <span style="color: #0000ff;">T (&amp;_Array)[N] )</span> &nbsp;<span style="color: #00ff00;">)[N]</span>;</p>
<p>&nbsp;</p>
<p>这是一个函数模板声明，没有定义实现体。<br />__countof_helper是一个函数（红色部分）；<br />其参数是一个&ldquo;数组引用&rdquo;T (&amp;)[N]（蓝色部分）；<br />而返回值是一个&ldquo;数组指针&rdquo;(指向一个数组的指针) char (*)[N]（绿色部分）；</p>
<p><br /><span style="font-size: small;"><strong>首先，需要理解3个C++的语法：</strong></span></p>
<p><br /><strong>1) 数组引用</strong>：</p>
<p>T (&amp;)[N] (注意：有个括号)。比如：<br />int a[5] = {0};<br />int (&amp;ra)[5] = a; 这里ra就是一个对数组a的引用，其这个数组的大小也是5；</p>
<p>&nbsp;</p>
<p>数组的信息包括：数组元素的类型，和数组的大小；声明&ldquo;数组引用&rdquo;时，类型和大小都要匹配，否则是错误的。比如：<br />int a[5] = {0}; <br />int (&amp;ra)[4] = a; //编译错误：error C2440: 'initializing' : cannot convert from 'int [5]' to 'int (&amp;)[4]'</p>
<p>&nbsp;</p>
<p>注意：C++里没有&ldquo;引用数组&rdquo;这个语法概念。"int &amp;ra[5]"这样的语法是通不过编译的。</p>
<p>&nbsp;</p>
<p><strong>2) 数组指针</strong>：</p>
<p>T (*)[N] (注意：有个括号)。比如：<br />int a[5];<br />int (*p)[5] = &amp;a;// 是一个指针，该指针指向&ldquo;一个有5个元素的数组&rdquo;；简称为&ldquo;数组指针&rdquo;</p>
<p>&nbsp;</p>
<p>同样，声明时类型和大小都要匹配，如下是错误的。<br />int a[4];<br />int (*p)[5] = &amp;a;//error C2440: '=' : cannot convert from 'int (*)[4]' to 'int (*)[5]'</p>
<p>&nbsp;</p>
<p>上面说了，C++不支持&ldquo;引用数组&rdquo;；但是&ldquo;指针数组&rdquo;是绝对支持的，平常都会经常到的。比如如下：<br />char * names[] = {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Mike",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "John",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Tom" };<br />names就是一个指针数组，该数组有3个元素，每个元素都是一个char类型指针，指向一个字符串。<br />从上面的例子可以看出，指针数组里面的指针所指向的那块内存区域里的数据大小可以是不同的。<br />因为指针本身所带的信息只知道被指的内存是什么数据类型，不知道大小信息。比如：<br />int a[4]; int b[5];<br />int * p = 0;<br />p = a; // ok<br />p = b; // ok</p>
<p>&nbsp;</p>
<p><strong>3) 函数返回&ldquo;数组指针&rdquo;的声明语法</strong>：</p>
<p>T (* Fun( param_list ) )[N];<br />Fun是一个函数，其返回值类型是 T (*)[N];</p>
<p>为什么不可以如下这么声明?<br />T (*)[N] Fun( param_list ); 这么声明多好理解啊。但是这么是不行的。<br />C++语法比较复杂，语言设计者对(),[],*,&amp;,&amp;&amp;这些符号所放的位置有特殊的要求。<br />&lt;&lt;Thinking in C++&gt;&gt;的第3章有一节&ldquo;Aside: complicated declarations &amp; definitions&rdquo;，举了一些复杂声明语法的例子。</p>
<p>&nbsp;</p>
<p><span style="font-size: small;"><strong>第二，需要知道的是：sizeof是在编译期完成的。<br /></strong></span>sizeof是C/C++语言中的keyword，不是函数。对其参数里的表达式是不会在执行期去执行的，而只是在编译期去推算整个表达式的最后的类型信息。<br />比如： int a = 1; sizeof(a++); cout &lt;&lt; a;&nbsp;&nbsp; // a还是1. 不会是2；<br />因为是在编译期完成，编译器只需要类型信息，不需要函数的实现体。所以就可以不用提供定义体。<br />下面这个例子可能更能说明这个问题。<br />int Fun(); // only declare it without definition<br />sizeof( Fun() );&nbsp; // 这里Fun()函数不会在运行的时候被执行，仅仅是在编译时，编译器需要知道的是：Fun()函数返回值的类型是什么。</p>
<p><br /><span style="font-size: small;"><strong>第三，需要理解的是&ldquo;模板自动推导(template deduction)&rdquo;</strong></span><br /><span style="color: #ff0000;">模板推导是由编译器在编译期(compile time)完成的，而不是在执行期(run time)完成的。</span></p>
<p>这个是理解的关键之一。不涉及内存布局分配的问题。编译期间，编译器只关心声明信息(也就是声明式里面所带的类型信息)。模板推导会自动推导模板参数的各种信息(类型，传递过来的数值等)。以下是一个例子：<br />template&lt;int x, int y&gt;<br />struct sum_<br />{<br />&nbsp; enum { value = x + y };<br />};<br />int sum = sum_&lt;3, 4&gt;::value; // sum的值在编译期间就已经确定下来了，不是在执行期间由CPU运算得到。<br />这个例子里的模板，仅仅只有数值的传递，没有包含类型。这个可能大家很少见到的。但是模板是支持的。</p>
<p>&nbsp;</p>
<p>例子二：<br />template&lt; typename T, size_t N&gt;<br />void Fun( T (&amp;)[N] );</p>
<p>这个模板里既有类型T，又有数值N；模板推导时，是根据Fun的实参来推导得到的。比如：<br />int a[5];<br />Fun(a); // 编译器经过推导就知道，T=int，N=5。注意这里的N能得到5，是因为Fun的参数声明决定的。这里Fun的参数是：数组引</p>
<p>用。对于&ldquo;数组引用&rdquo;，上面说过，编译器能够从实参那里知道数组的类型，又能知道数组的大小。</p>
<p>&nbsp;</p>
<p>同时，编译器在进行模板推导时，会对&ldquo;实参&rdquo;和&ldquo;形参&rdquo;能够匹配的所有情况进行推导，经过所有的尝试都不能匹配，就会报告编译失败信息。比如，对于这个例子，我们将一个指针作为实参传递给它：<br />int * p = NULL;<br />Fun( p ); // error C2784: 'void Fun(T (&amp;)[N])' : could not deduce template argument for 'T (&amp;)[N]' from 'int *'<br />因为一个指针不可能赋值给一个数组引用。所以编译就会出错。</p>
<p><br />所以对于stdlib.h里的这个_countof()，如果传递一个指针给它，编译就会失败。</p>
<p>&nbsp;</p>
<p>同时，需要指出的是，VC6对模板支持的很不好，一些复杂的模板语法就编译不了。根据我的测试，就这里所说的_countof()，在VC6里就编译不了。VC2005/2008就已经支持的很好的。所以这个_countof()是在VC2005中才提供的。在VC6所带的stdlib.h里没有这个_countof()宏的。</p>
<p>&nbsp;</p>
<p>【题外话：模板是泛型编程的基础。利用模板自动推导的能力，可以构建出很有技巧性的代码实现。比如：Boost库。更甚者：Loki库&lt;Modern C++ Design&gt;(中文名：C++设计新思维)这本书附带的库。关于模板的语法和自动推导，可以看&lt;C++ Templates the </p>
<p>complete guide&gt;，大陆翻译的中译本编译的不好。侯捷翻译的《C++ Templates全览》比较好，网上有电子的pdf可以找到，但是只</p>
<p>能在电脑上看，不能打印，也不能copy里面的文字。】</p>
<p>&nbsp;</p>
<p><span style="font-size: small;"><strong>第四：注意事项</strong></span><br />template &lt;typename _CountofType, size_t _SizeOfArray&gt;<br />char (<span style="color: #ff0000;">*</span>__countof_helper(UNALIGNED _CountofType (&amp;_Array)[_SizeOfArray]))[_SizeOfArray];<br />#define _countof(_Array) sizeof(<span style="color: #ff0000;">*</span>__countof_helper(_Array))</p>
<p>&nbsp;</p>
<p><strong>a)</strong> #define里的sizeof()的参数是 &ldquo;<span style="color: #ff0000;">*</span>__countof_helper(_Array)&rdquo;（注意：有个*），而不是&ldquo;__countof_helper(_Array)&rdquo;，<br />如果是&ldquo;__countof_helper(_Array)&rdquo;，那么_countof()返回的值永远是一个指针的大小(在32位系统上总是4)。<br />因为__countof_helper返回的是一个&ldquo;数组指针&rdquo;，加上*，就是取得该指针所指向的数组。</p>
<p><br />sizeof(一个指针)和sizeof(一个数组)，是有很大的区别的。看下面的例子：</p>
<p><br />int a[5];<br />int *p = a;<br />int (*pa)[5] = &amp;a;</p>
<p><br />// p和pa都是指针，但是指针的类型不同：p的类型是int*；pa的类型是int(*)[5]。</p>
<p><br />sizeof(p)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // = 4;<br />sizeof(a)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // = 20 = 5*sizeof(int)<br />sizeof(*p)&nbsp;&nbsp;&nbsp;&nbsp; // = sizeof(int) = 4;<br />sizeof(pa)&nbsp;&nbsp;&nbsp; // = 4;<br />sizeof(*pa)&nbsp; // = sizeof(a) = 20;</p>
<p>&nbsp;</p>
<p>C/C++对于数组和指针是明确区分其类型的。数组的信息包括(类型+大小)，而指针则没有大小信息。<br />在这里附带要说一下，数组经过函数参数传递后，数组的大小信息就丢失了。比如：<br />void Fun( int a[5] )<br />{ <br />&nbsp;&nbsp; int n = sizeof(a);&nbsp; // n为4，相对于就是sizeof(int*).因为编译器只传递过来了数组的地址，大小信息没有了。<br />}</p>
<p><br />所以,上面Fun的参数声明里面的数组的具体数字是被忽略掉的。其等价声明式可以是：<br />void Fun( int a[10] );<br />void Fun( int a[] );<br />void Fun( int *a );</p>
<p><br />为了需要把大小信息传递到函数里面去，需要额外加一个参数来表示大小信息，这个大小信息需要调用者来提供，并且有调用者来保证大小信息的正确性。<br />void Fun( int a[], int size );<br />或者使用stl里的vector模板类来代替：void Fun( vector&lt;int&gt;&amp; v); 因为vector是一个类，它有size()方法能得到大小信息。</p>
<p>&nbsp;</p>
<p><strong>b)</strong>__countof_helper函数的类型是char，而不是_CountofType。因为sizeof( * (char(*)[N]) )【注：这么写只是为了示范说明，</p>
<p>在代码里不能这么写，通不过编译的】 刚好等于N，因为sizeof(char)在任何操作系统上都是=1；</p>
<p>&nbsp;</p>
<p><strong>c)</strong> 这个模板函数只有声明(declaration)，没有定义(definition)。没有定义体的原因是：sizeof是在编译期完成的，不需要具体</p>
<p>的定义体出现（上面第二点里说了）。同时，模板推导也是在编译期完成的。所以_countof()整个宏在编译期就完成了。不需要函</p>
<p>数的具体实现体。<br />如果定义了实现体，_countof依然能工作，但是那些实现体都是不会被用到的，而这些实现体会在程序运行起来之后，加载到内存</p>
<p>里。这样就浪费内存了。<br />因为__countof_helper()没有定义体，所以使用的时候只能使用_countof宏本身，可不要像下面那样调用__countof_helper()。<br />int a[5];<br />__countof_helper(a); // 能编译通过，但是链接时，链接器会告诉你找不到实现体。</p>
<p><br /><strong>d)</strong> google chrome浏览器源代码里也有一个类似的宏如下：<br /><span style="color: #ff6600;">template &lt;typename T, size_t N&gt;<br />char (<span style="color: #0000ff;">&amp;</span>ArraySizeHelper(T (&amp;array)[N]))[N]; <br />#define arraysize(array) (sizeof(ArraySizeHelper(array)))</span><br />跟_countof的区别是：<br />1) ArraySizeHelper函数返回的是 char (&amp;)[N]，而不是char (*)[N]；<br />2) #define里没有*号。因为sizeof( char (&amp;)[N] ) = N;</p>
<p>&nbsp;</p>
<p>为什么stdlib.h里的_countof宏，不用&amp;，而要用*？<br />在winnt.h里其实也有个同样功能的宏RTL_NUMBER_OF_V2【注：VC6里没有，VC2005才提供的】，其中有</p>
<p>一句注释是这样的：<br />&ldquo;We could return a reference instead of a pointer but older compilers do not accept that.&rdquo;:)<br />That's it.</p>
<p>&nbsp;</p>
<p>winnt.h 里的注释说明的很好，值得看看。摘抄如下：<br />//<br />// RtlpNumberOf is a function that takes a reference to an array of N Ts.<br />//<br />// typedef T array_of_T[N];<br />// typedef array_of_T &amp;reference_to_array_of_T;<br />//<br />// RtlpNumberOf returns a pointer to an array of N chars.<br />// We could return a reference instead of a pointer but older compilers do not accept that.<br />//<br />// typedef char array_of_char[N];<br />// typedef array_of_char *pointer_to_array_of_char;<br />//<br />// <span style="color: #ff0000;">sizeof(array_of_char) == N</span><br />// <span style="color: #ff0000;">sizeof(<span style="color: #0000ff;">*</span>pointer_to_array_of_char) == N<br /></span>//<br />// pointer_to_array_of_char RtlpNumberOf(reference_to_array_of_T);<br />//<br />// <strong>We never even call RtlpNumberOf, we just take the size of dereferencing its return type.<br /></strong>// <strong>We do not even implement RtlpNumberOf, we just decare it.<br /></strong>//<br />// <strong>Attempts to pass pointers instead of arrays to this macro result in compile time errors.<br /></strong>// That is the point.<br />//<br />extern "C++" // templates cannot be declared to have 'C' linkage<br />template &lt;typename T, size_t N&gt;<br />char (*RtlpNumberOf( UNALIGNED T (&amp;)[N] ))[N];</p>
<p>#define RTL_NUMBER_OF_V2(A) (sizeof(*RtlpNumberOf(A)))</p>
<p>&nbsp;</p>
<p>P.S. 下面这个链接值得看。其中的解释相当好。<br /><a href="http://blogs.msdn.com/the1/archive/2004/05/07/128242.aspx">http://blogs.msdn.com/the1/archive/2004/05/07/128242.aspx</a></p>
<p>&nbsp;</p>
<p>附图：一些语法</p>
<p><img src="http://hi.csdn.net/attachment/201004/11/0_1270975252hcrP.gif" alt="" /></p>
</div>




<!-- Baidu Button BEGIN -->

<div class="bdsharebuttonbox" style="float: right;">
<a href="#" class="bds_more" data-cmd="more" style="background-position:0 0 !important; background-image: url(http://bdimg.share.baidu.com/static/api/img/share/icons_0_16.png?v=d754dcc0.png) !important"></a>
<a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"  style="background-position:0 -52px !important"></a>
<a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"style="background-position:0 -104px !important"></a>
<a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"style="background-position:0 -260px !important"></a>
<a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"style="background-position:0 -208px !important"></a>
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"style="background-position:0 -1612px !important" ></a>
</div>
<script>window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "1", "bdMiniList": false, "bdPic": "", "bdStyle": "0", "bdSize": "16" }, "share": {} }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];</script>
<!-- Baidu Button END -->

<!--192.168.100.35-->
<ul class="article_next_prev">
            <li class="prev_article"><span  onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shangyipian']);location.href='/yuanmanzheng/article/details/5471487';">上一篇</span><a href="/yuanmanzheng/article/details/5471487" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shangyipian'])">多线程：PostThreadMessage 消息可能会丢失</a></li>
</ul>

<!-- Baidu Button BEGIN -->
<script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=1536434" ></script>
<script type="text/javascript" id="bdshell_js"></script>
<script type="text/javascript">
    document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
</script>
<!-- Baidu Button END -->


</div>
      <dl class="blog-associat-tag">
        <dt>主题推荐</dt>
        <dd>
                <a href="http://www.csdn.net/tag/google chrome" target="_blank" class="blog-tage-red" >google chrome</a> 
                <a href="http://www.csdn.net/tag/操作系统" target="_blank" class="blog-tage-red" >操作系统</a> 
                <a href="http://www.csdn.net/tag/32位" target="_blank" class="blog-tage-red" >32位</a> 
                <a href="http://www.csdn.net/tag/源代码" target="_blank" class="blog-tage-red" >源代码</a> 
                <a href="http://www.csdn.net/tag/浏览器" target="_blank" class="blog-tage-red" >浏览器</a> 
        </dd>
    </dl> 


<dl class="blog-ass-articl tracking-ad"  data-mod="popu_36" id="res-relatived"> 
     <dt><span>猜你在找</span></dt>    
</dl>
<div id="job_blog_reco">
<script src="http://csdnimg.cn/jobreco/job_reco.js" type="text/javascript"></script>
   
     <script type="text/javascript">
         csdn.position.show({
         sourceType: "blog",
         tplType: "blogDetail",
         searchType: "detail",
         searchKey: "5472967",
             username: "cnheike",
         containerId: "job_blog_reco"
        }); 
    </script>

</div>

<script type="text/javascript">
    var searchtitletags = '如何理解stdlib.h里的_countof()宏' + ',' + 'google chrome,操作系统,32位,源代码,浏览器';
    searchService({
        index: 'blog',
        query: searchtitletags,
        from: 10,
        size: 10,
        appendTo: '#res-relatived',
        url: 'recommend',
        his: 2,
        client: "blog_cf_enhance",
        tmpl: '<dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="#{ url }" title="#{ title }" strategy="#{ strategy }">#{ title }</a></dd>'
    });

 </script>   



    <div id="ad_cen">
   
          <script type="text/javascript">
              new Ad(4, 'ad_cen');
          </script>
    </div>
<div class="comment_class">
    <div id="comment_title" class="panel_head">
        <span class="see_comment">查看评论</span><a name="comments"></a></div>
    <div id="comment_list">
    </div>
    <div id="comment_bar">
    </div>
    <div id="comment_form">
    </div>

    <div class="announce">
        * 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场<a name="reply"></a><a name="quote"></a></div>
</div>

<script type="text/javascript">
    var fileName = '5472967';
    var commentscount = 8;
    var islock = false
</script>
<script type="text/javascript" src="http://static.blog.csdn.net/scripts/comment.js"></script>
    <div id="ad_bot">
    </div>
    <script type="text/javascript">
    new Ad(5, 'ad_bot');
    </script>
<div id="report_dialog">
</div>

<div id="d-top"  style="bottom:60px;">
        <a id="quick-reply" class="btn btn-top q-reply" title="快速回复" style="display:none;">
            <img src="http://static.blog.csdn.net/images/blog-icon-reply.png" alt="快速回复">
        </a>    

    <a id="d-top-a" class="btn btn-top backtop"  style="display: none;" title="返回顶部" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_huidaodingbu'])" style="">         
         <img src="http://static.blog.csdn.net/images/top.png" alt="TOP">
    </a>
</div>
<script type="text/javascript">
    $(function ()
    {
        $("#ad_frm_0").height("90px");
        
        setTimeout(function(){
            $("#ad_frm_2").height("200px");
        },1000);
        
        /*
        if($("#comment_content").length>0)
        {
            $("#quick-reply").show();

            $("#quick-reply").click(function(){
                setEditorFocus();
            });
        }       
     
        var d_top = $('#d-top-a');

        document.onscroll = function ()
        {
            var scrTop = (document.body.scrollTop || document.documentElement.scrollTop);
            if (scrTop > 500)
            {
                d_top.show();
            } else
            {
                d_top.hide();
            }
        }
        $('#d-top-a').click(function ()
        {
            scrollTo(0, 0);
            this.blur();
            return false;
        });
        */
    });
  
</script>
<style type="text/css">
    .tag_list
    {
        background: none repeat scroll 0 0 #FFFFFF;
        border: 1px solid #D7CBC1;
        color: #000000;
        font-size: 12px;
        line-height: 20px;
        list-style: none outside none;
        margin: 10px 2% 0 1%;
        padding: 1px;
    }
    .tag_list h5
    {
        background: none repeat scroll 0 0 #E0DBD3;
        color: #47381C;
        font-size: 12px;
        height: 24px;
        line-height: 24px;
        padding: 0 5px;
        margin: 0;
    }
    .tag_list h5 a
    {
        color: #47381C;
    }
    .classify
    {
        margin: 10px 0;
        padding: 4px 12px 8px;
    }
    .classify a
    {
        margin-right: 20px;
        white-space: nowrap;
    }
</style>
<div class="tag_list">
    <h5>
        <a href="http://www.csdn.net/tag/" target="_blank">核心技术类目</a></h5>
    <div class="classify">
<a title="全部主题" href="http://www.csdn.net/tag" target="_blank" onclick="LogClickCount(this,336);">全部主题</a>
<a title="Hadoop" href="http://g.csdn.net/5272865" target="_blank" onclick="LogClickCount(this,336);">Hadoop</a>
<a title="AWS" href="http://g.csdn.net/5272866" target="_blank" onclick="LogClickCount(this,336);">AWS</a>
<a title="移动游戏" href="http://g.csdn.net/5272870" target="_blank" onclick="LogClickCount(this,336);">移动游戏</a>
<a title="Java" href="http://g.csdn.net/5272871" target="_blank" onclick="LogClickCount(this,336);">Java</a>
<a title="Android" href="http://g.csdn.net/5272872" target="_blank" onclick="LogClickCount(this,336);">Android</a>
<a title="iOS" href="http://g.csdn.net/5272873" target="_blank" onclick="LogClickCount(this,336);">iOS</a>
<a title="Swift" href="http://g.csdn.net/5272868" target="_blank" onclick="LogClickCount(this,336);">Swift</a>
<a title="智能硬件" href="http://g.csdn.net/5272869" target="_blank" onclick="LogClickCount(this,336);">智能硬件</a>
<a title="Docker" href="http://g.csdn.net/5272867" target="_blank" onclick="LogClickCount(this,336);">Docker</a>
<a title="OpenStack" href="http://g.csdn.net/5272925" target="_blank" onclick="LogClickCount(this,336);">OpenStack</a>
<a title="VPN" href="http://www.csdn.net/tag/vpn" target="_blank" onclick="LogClickCount(this,336);">VPN</a>
<a title="Spark" href="http://g.csdn.net/5272924" target="_blank" onclick="LogClickCount(this,336);">Spark</a>
<a title="ERP" href="http://www.csdn.net/tag/erp" target="_blank" onclick="LogClickCount(this,336);">ERP</a>
<a title="IE10" href="http://www.csdn.net/tag/ie10" target="_blank" onclick="LogClickCount(this,336);">IE10</a>
<a title="Eclipse" href="http://www.csdn.net/tag/eclipse" target="_blank" onclick="LogClickCount(this,336);">Eclipse</a>
<a title="CRM" href="http://www.csdn.net/tag/crm" target="_blank" onclick="LogClickCount(this,336);">CRM</a>
<a title="JavaScript" href="http://www.csdn.net/tag/javascript" target="_blank" onclick="LogClickCount(this,336);">JavaScript</a>
<a title="数据库" href="http://www.csdn.net/tag/数据库" target="_blank" onclick="LogClickCount(this,336);">数据库</a>
<a title="Ubuntu" href="http://www.csdn.net/tag/ubuntu" target="_blank" onclick="LogClickCount(this,336);">Ubuntu</a>
<a title="NFC" href="http://www.csdn.net/tag/nfc" target="_blank" onclick="LogClickCount(this,336);">NFC</a>
<a title="WAP" href="http://www.csdn.net/tag/wap" target="_blank" onclick="LogClickCount(this,336);">WAP</a>
<a title="jQuery" href="http://www.csdn.net/tag/jquery" target="_blank" onclick="LogClickCount(this,336);">jQuery</a>
<a title="BI" href="http://www.csdn.net/tag/bi" target="_blank" onclick="LogClickCount(this,336);">BI</a>
<a title="HTML5" href="http://www.csdn.net/tag/html5" target="_blank" onclick="LogClickCount(this,336);">HTML5</a>
<a title="Spring" href="http://www.csdn.net/tag/spring" target="_blank" onclick="LogClickCount(this,336);">Spring</a>
<a title="Apache" href="http://www.csdn.net/tag/apache" target="_blank" onclick="LogClickCount(this,336);">Apache</a>
<a title=".NET" href="http://www.csdn.net/tag/.net" target="_blank" onclick="LogClickCount(this,336);">.NET</a>
<a title="API" href="http://www.csdn.net/tag/api" target="_blank" onclick="LogClickCount(this,336);">API</a>
<a title="HTML" href="http://www.csdn.net/tag/html" target="_blank" onclick="LogClickCount(this,336);">HTML</a>
<a title="SDK" href="http://www.csdn.net/tag/sdk" target="_blank" onclick="LogClickCount(this,336);">SDK</a>
<a title="IIS" href="http://www.csdn.net/tag/iis" target="_blank" onclick="LogClickCount(this,336);">IIS</a>
<a title="Fedora" href="http://www.csdn.net/tag/fedora" target="_blank" onclick="LogClickCount(this,336);">Fedora</a>
<a title="XML" href="http://www.csdn.net/tag/xml" target="_blank" onclick="LogClickCount(this,336);">XML</a>
<a title="LBS" href="http://www.csdn.net/tag/lbs" target="_blank" onclick="LogClickCount(this,336);">LBS</a>
<a title="Unity" href="http://www.csdn.net/tag/unity" target="_blank" onclick="LogClickCount(this,336);">Unity</a>
<a title="Splashtop" href="http://www.csdn.net/tag/splashtop" target="_blank" onclick="LogClickCount(this,336);">Splashtop</a>
<a title="UML" href="http://www.csdn.net/tag/uml" target="_blank" onclick="LogClickCount(this,336);">UML</a>
<a title="components" href="http://www.csdn.net/tag/components" target="_blank" onclick="LogClickCount(this,336);">components</a>
<a title="Windows Mobile" href="http://www.csdn.net/tag/windowsmobile" target="_blank" onclick="LogClickCount(this,336);">Windows Mobile</a>
<a title="Rails" href="http://www.csdn.net/tag/rails" target="_blank" onclick="LogClickCount(this,336);">Rails</a>
<a title="QEMU" href="http://www.csdn.net/tag/qemu" target="_blank" onclick="LogClickCount(this,336);">QEMU</a>
<a title="KDE" href="http://www.csdn.net/tag/kde" target="_blank" onclick="LogClickCount(this,336);">KDE</a>
<a title="Cassandra" href="http://www.csdn.net/tag/cassandra" target="_blank" onclick="LogClickCount(this,336);">Cassandra</a>
<a title="CloudStack" href="http://www.csdn.net/tag/cloudstack" target="_blank" onclick="LogClickCount(this,336);">CloudStack</a>
<a title="FTC" href="http://www.csdn.net/tag/ftc" target="_blank" onclick="LogClickCount(this,336);">FTC</a>
<a title="coremail" href="http://www.csdn.net/tag/coremail" target="_blank" onclick="LogClickCount(this,336);">coremail</a>
<a title="OPhone " href="http://www.csdn.net/tag/ophone " target="_blank" onclick="LogClickCount(this,336);">OPhone </a>
<a title="CouchBase" href="http://www.csdn.net/tag/couchbase" target="_blank" onclick="LogClickCount(this,336);">CouchBase</a>
<a title="云计算" href="http://www.csdn.net/tag/云计算" target="_blank" onclick="LogClickCount(this,336);">云计算</a>
<a title="iOS6" href="http://www.csdn.net/tag/iOS6" target="_blank" onclick="LogClickCount(this,336);">iOS6</a>
<a title="Rackspace " href="http://www.csdn.net/tag/rackspace " target="_blank" onclick="LogClickCount(this,336);">Rackspace </a>
<a title="Web App" href="http://www.csdn.net/tag/webapp" target="_blank" onclick="LogClickCount(this,336);">Web App</a>
<a title="SpringSide" href="http://www.csdn.net/tag/springside" target="_blank" onclick="LogClickCount(this,336);">SpringSide</a>
<a title="Maemo" href="http://www.csdn.net/tag/maemo" target="_blank" onclick="LogClickCount(this,336);">Maemo</a>
<a title="Compuware" href="http://www.csdn.net/tag/compuware" target="_blank" onclick="LogClickCount(this,336);">Compuware</a>
<a title="大数据" href="http://www.csdn.net/tag/大数据" target="_blank" onclick="LogClickCount(this,336);">大数据</a>
<a title="aptech" href="http://www.csdn.net/tag/aptech" target="_blank" onclick="LogClickCount(this,336);">aptech</a>
<a title="Perl" href="http://www.csdn.net/tag/perl" target="_blank" onclick="LogClickCount(this,336);">Perl</a>
<a title="Tornado" href="http://www.csdn.net/tag/tornado" target="_blank" onclick="LogClickCount(this,336);">Tornado</a>
<a title="Ruby" href="http://www.csdn.net/tag/ruby" target="_blank" onclick="LogClickCount(this,336);">Ruby</a>
<a title="Hibernate" href="http://www.csdn.net/hibernate" target="_blank" onclick="LogClickCount(this,336);">Hibernate</a>
<a title="ThinkPHP" href="http://www.csdn.net/tag/thinkphp" target="_blank" onclick="LogClickCount(this,336);">ThinkPHP</a>
<a title="HBase" href="http://www.csdn.net/tag/hbase" target="_blank" onclick="LogClickCount(this,336);">HBase</a>
<a title="Pure" href="http://www.csdn.net/tag/pure" target="_blank" onclick="LogClickCount(this,336);">Pure</a>
<a title="Solr" href="http://www.csdn.net/tag/solr" target="_blank" onclick="LogClickCount(this,336);">Solr</a>
<a title="Angular" href="http://www.csdn.net/tag/angular" target="_blank" onclick="LogClickCount(this,336);">Angular</a>
<a title="Cloud Foundry" href="http://www.csdn.net/tag/cloudfoundry" target="_blank" onclick="LogClickCount(this,336);">Cloud Foundry</a>
<a title="Redis" href="http://www.csdn.net/tag/redis" target="_blank" onclick="LogClickCount(this,336);">Redis</a>
<a title="Scala" href="http://www.csdn.net/tag/scala" target="_blank" onclick="LogClickCount(this,336);">Scala</a>
<a title="Django" href="http://www.csdn.net/tag/django" target="_blank" onclick="LogClickCount(this,336);">Django</a>
<a title="Bootstrap" href="http://www.csdn.net/tag/bootstrap" target="_blank" onclick="LogClickCount(this,336);">Bootstrap</a>
    </div>
</div>

<div id="pop_win" style="display:none ;position: absolute; z-index: 10000; border: 1px solid rgb(220, 220, 220); top: 222.5px; left: 630px; opacity: 1; background: none 0px 0px repeat scroll rgb(255, 255, 255);">
    
</div>
<div id="popup_mask"></div>
<style>
    #popup_mask
    {
        position: absolute;
        width: 100%;
        height: 100%;
        background: #000;
        z-index: 9999;
        left: 0px;
        top: 0px;
        opacity: 0.3;
        filter: alpha(opacity=30);
        display: none;
    }

</style>




<script type="text/javascript">
    $(function(){
        setTimeout(function(){
            $(".comment_body:contains('回复')").each(function(index,item){
                var u=$(this).text().split('：')[0].toString().replace("回复","")
                var thisComment=$(this);
                if(u)
                {
                    $.getJSON("https://passport.csdn.net/get/nick?callback=?", {users: u}, function(a) {
                        if(a!=null&&a.data!=null&&a.data.length>0)
                        {
                            nick=a.data[0].n; 
                            if(u!=nick)
                            {
                                thisComment.text(thisComment.text().replace(u,nick));  
                            }
                        }       
                    });  
                }
            });
        },200);  
        
        setTimeout(function(){
            $("a img[src='http://js.tongji.linezing.com/stats.gif']").parent().css({"position":"absolute","left":"50%"});
        },300);
    });

    function loginbox(){
        var $logpop=$("#pop_win");
        $logpop.html('<iframe src="https://passport.csdn.net/account/loginbox?service=http://static.blog.csdn.net/callback.htm" frameborder="0" height="600" width="400" scrolling="no"></iframe>');

        $('#popup_mask').css({
            opacity: 0.5,
            width: $( document ).width() + 'px',
            height:  $( document ).height() + 'px'
        });
        $('#popup_mask').css("display","block");
 
        $logpop.css( {
            top: ($( window ).height() - $logpop.height())/ 2  + $( window 
       ).scrollTop() + 'px',
            left:($( window ).width() - $logpop.width())/ 2
        } );
 
        setTimeout( function () {
            $logpop.show();
            $logpop.css( {
                opacity: 1
            } );
        }, 200 );
 
        $('#popup_mask').unbind("click");
        $('#popup_mask').bind("click", function(){
            $('#popup_mask').hide();
            var $clopop = $("#pop_win");
            $("#common_ask_div_sc").css("display","none");
            $clopop.css( {
                opacity: 0
            } );
            setTimeout( function () {
                $clopop.hide();
            }, 350 );
            return false;
        });
    }    

</script>
                        <div class="clear">
                        </div>
                    </div>                   
                
            </div>
            <div id="side">
    <div class="side">
<div id="panel_Profile" class="panel">
<ul class="panel_head"><span>个人资料</span></ul>
<ul class="panel_body profile">
<div id="blog_userface">
    <a href="http://my.csdn.net/yuanmanzheng" target="_blank">
    <img src="http://avatar.csdn.net/6/7/9/1_yuanmanzheng.jpg" title="访问我的空间" style="max-width:90%"/>
    </a>
    <br />
    <span><a href="http://my.csdn.net/yuanmanzheng" class="user_name" target="_blank">yuanmanzheng</a></span>
</div>
<div class="interact">
<a href="javascript:void(0);" class="attent" id="span_add_follow" title="[加关注]" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_guanzhu'])"></a>

 <a href="javascript:void(0);" class="letter"  title="[发私信]" onclick="window.open('http://msg.csdn.net/letters/model?receiver=yuanmanzheng','_blank','height=350,width=700');_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_sixin'])"></a>  
</div>
<div id="blog_medal">
                <div id="bms_box">
               </div>
</div>
<ul id="blog_rank">
    <li>访问：<span>9344次</span></li>
    <li>积分：<span>149</span> </li>    
    <li >等级： <span style="position:relative;display:inline-block;z-index:1" >
            <img src="http://csdnimg.cn/jifen/images/xunzhang/jianzhang/blog2.png" alt="" style="vertical-align: middle;" id="leveImg">
            <div id="smallTittle" style=" position: absolute;  left: -24px;  top: 25px;  text-align: center;  width: 101px;  height: 32px;  background-color: #fff;  line-height: 32px;  border: 2px #DDDDDD solid;  box-shadow: 0px 2px 2px rgba (0,0,0,0.1);  display: none;   z-index: 999;">
            <div style="left: 42%;  top: -8px;  position: absolute;  width: 0;  height: 0;  border-left: 10px solid transparent;  border-right: 10px solid transparent;  border-bottom: 8px solid #EAEAEA;"></div>
            积分：149 </div>
        </span>  </li>
    <li>排名：<span>千里之外</span></li>
</ul>
<ul id="blog_statistics">
    <li>原创：<span>4篇</span></li>
    <li>转载：<span>0篇</span></li>
    <li>译文：<span>0篇</span></li>
    <li>评论：<span>13条</span></li>
</ul>
</ul>
</div>


<div class="panel" id="panel_Search">
    <ul class="panel_head"><span>文章搜索</span></ul>
    <ul class="panel_body">
        <form id="frmSearch" action="http://so.csdn.net/search" class="form_search" target="_blank">
        <span><input id="inputSearch" type="text" class="blogsearch" title="请输入关键字" /></span>
        <input id="btnSubmit" type="button" value="搜索" title="search in blog" />
        <input type="hidden" name="q" id="inputQ" />
        <input type="hidden" name="t" value="blog" />
        <a id="btnSearchBlog" target="_blank"></a>
        </form>
    </ul>
</div>

<script type="text/javascript">
    $(function () {
        $("#btnSubmit").click(function () {           
            search();
        });

        $("#frmSearch").submit(function () {
            search();
            return false;
        });

        function search()
        {
            var url = "http://so.csdn.net/so/search/s.do?q=" + encodeURIComponent($("#inputSearch").val()) + "&u=" + username + "&t=blog";
            window.location.href = url;
        }   
    });
</script><div id="panel_Archive" class="panel">
<ul class="panel_head"><span>文章存档</span></ul>
<ul class="panel_body">
<div id="archive_list">
<!--归档统计-->
<li><a href="http://blog.csdn.net/yuanmanzheng/article/month/2010/04">2010年04月</a><span>(3)</span></li><li><a href="http://blog.csdn.net/yuanmanzheng/article/month/2002/11">2002年11月</a><span>(1)</span></li>
</div>
</ul>
</div>
<div id="hotarticls" class="panel">
<ul class="panel_head">
    <span>       
阅读排行    </span>
</ul>

<ul class="panel_body itemlist">
<li>
<a href="/yuanmanzheng/article/details/5471487" title="多线程：PostThreadMessage 消息可能会丢失">多线程：PostThreadMessage 消息可能会丢失</a><span>(3471)</span>
</li>
<li>
<a href="/yuanmanzheng/article/details/5472967" title="如何理解stdlib.h里的_countof()宏">如何理解stdlib.h里的_countof()宏</a><span>(2865)</span>
</li>
<li>
<a href="/yuanmanzheng/article/details/5469668" title="多线程绘图之：Multiple Threads and GDI Objects">多线程绘图之：Multiple Threads and GDI Objects</a><span>(1606)</span>
</li>
<li>
<a href="/yuanmanzheng/article/details/14521" title="有关于JAVA中的CLASSPATH的作用">有关于JAVA中的CLASSPATH的作用</a><span>(653)</span>
</li>
</ul>
</div>
<div id="hotarticls2" class="panel">
<ul class="panel_head"><span>评论排行</span></ul>
<ul class="panel_body itemlist">
<li>
<a href="/yuanmanzheng/article/details/5472967" title="如何理解stdlib.h里的_countof()宏">如何理解stdlib.h里的_countof()宏</a><span>(8)</span>
</li>
<li>
<a href="/yuanmanzheng/article/details/5471487" title="多线程：PostThreadMessage 消息可能会丢失">多线程：PostThreadMessage 消息可能会丢失</a><span>(5)</span>
</li>
<li>
<a href="/yuanmanzheng/article/details/14521" title="有关于JAVA中的CLASSPATH的作用">有关于JAVA中的CLASSPATH的作用</a><span>(0)</span>
</li>
<li>
<a href="/yuanmanzheng/article/details/5469668" title="多线程绘图之：Multiple Threads and GDI Objects">多线程绘图之：Multiple Threads and GDI Objects</a><span>(0)</span>
</li>
</ul>
</div>
<div id="homepageArticles" class="panel tracking-ad" data-mod="popu_4">
<ul class="panel_head"><span>推荐文章</span></ul>
<ul class="panel_body" id="ad_commend"></ul>
</div>
<script type="text/javascript">
 new Ad(12, 'ad_commend');
</script><div id="newcomments" class="panel">
<ul class="panel_head"><span>最新评论</span></ul>
<ul class="panel_body itemlist">
    <li>
   
         <a href="/yuanmanzheng/article/details/5472967#comments">如何理解stdlib.h里的_countof()宏</a>
    <p style="margin:0px;"><a href="/FrightingGuo" class="user_name">FrightingGuo</a>:
明白了，谢谢啊
    </p>
    </li>
    <li>
   
         <a href="/yuanmanzheng/article/details/5471487#comments">多线程：PostThreadMessage 消息可能会丢失</a>
    <p style="margin:0px;"><a href="/xqhrs232" class="user_name">xqhrs232</a>:
我遇到的情况是老是收的线程老是收不到PostThreadMessage()函数发过去的消息，看MSD...
    </p>
    </li>
    <li>
   
         <a href="/yuanmanzheng/article/details/5471487#comments">多线程：PostThreadMessage 消息可能会丢失</a>
    <p style="margin:0px;"><a href="/zhouze8002" class="user_name">zhouze8002</a>:
PostThreadMessage()丢失情况弄了我一天啊，我的情况是用子线程传递消息给主线程创建的...
    </p>
    </li>
    <li>
   
         <a href="/yuanmanzheng/article/details/5471487#comments">多线程：PostThreadMessage 消息可能会丢失</a>
    <p style="margin:0px;"><a href="/bobjoychen" class="user_name">bobjoychen</a>:
PostMessage也存在丢失的情况我这边是这样一个情况，用了一个高精度定时器，1ms执行一次任务...
    </p>
    </li>
    <li>
   
         <a href="/yuanmanzheng/article/details/5471487#comments">多线程：PostThreadMessage 消息可能会丢失</a>
    <p style="margin:0px;"><a href="/xzhdy" class="user_name">xzhdy</a>:
挺好
    </p>
    </li>
    <li>
   
         <a href="/yuanmanzheng/article/details/5471487#comments">如何理解stdlib.h里的_countof()宏</a>
    <p style="margin:0px;"><a href="/nieyanbing19870820" class="user_name">nieyanbing19870820</a>:
不得不顶
    </p>
    </li>
    <li>
   
         <a href="/yuanmanzheng/article/details/5471487#comments">如何理解stdlib.h里的_countof()宏</a>
    <p style="margin:0px;"><a href="/CoffeeCN" class="user_name">CoffeeCN</a>:
__countof_helper是一个函数指针，返回的是一个数组
    </p>
    </li>
    <li>
   
         <a href="/yuanmanzheng/article/details/5471487#comments">如何理解stdlib.h里的_countof()宏</a>
    <p style="margin:0px;"><a href="/miyunhong" class="user_name">miyunhong</a>:
分析得 太透彻了，，可以 做为 一个 很好的面试题，，呵呵，，转载了，，
    </p>
    </li>
    <li>
   
         <a href="/yuanmanzheng/article/details/5471487#comments">如何理解stdlib.h里的_countof()宏</a>
    <p style="margin:0px;"><a href="/assassin5616" class="user_name">assassin5616</a>:
每次看到这个函数我都有些纳闷，在什么情况下才会用到这个函数？ 一般静态数组我们不是都直接知道它的大小...
    </p>
    </li>
    <li>
   
         <a href="/yuanmanzheng/article/details/5471487#comments">如何理解stdlib.h里的_countof()宏</a>
    <p style="margin:0px;"><a href="/Bruce_Jee" class="user_name">Bruce_Jee</a>:
写得不错
    </p>
    </li>
</ul>
</div>
    </div>
    <div class="clear">
    </div>
</div>

            <div class="clear">
            </div>
        </div>
        

<script type="text/javascript" src="http://csdnimg.cn/rabbit/cnick/cnick.js"></script>
<script type="text/javascript" src="http://static.blog.csdn.net/scripts/newblog.min.js"></script>


<script type="text/javascript" src="http://medal.blog.csdn.net/showblogmedal.ashx?blogid=2156"></script>
<script type="text/javascript" src="http://static.blog.csdn.net/scripts/JavaScript1.js"></script>

<script type="text/javascript">document.write("<img src=http://counter.csdn.net/pv.aspx?id=24 border=0 width=0 height=0>");</script>
<script type="text/javascript" src="http://www.csdn.net/ui/scripts/Csdn/counter.js"></script>
<script type="text/javascript" src="http://ad.csdn.net/scripts/ad-blog.js"></script>
<script type="text/javascript" src="http://zz.csdn.net/js/count.js"></script>
<script type="text/javascript">
    $(function () {
        function __get_code_toolbar(snippet_id) {
            return $("<a href='https://code.csdn.net/snippets/"
                    + snippet_id
                    + "' target='_blank' title='在CODE上查看代码片' style='text-indent:0;'><img src='https://code.csdn.net/assets/CODE_ico.png' width=12 height=12 alt='在CODE上查看代码片' style='position:relative;top:1px;left:2px;'/></a>"
                    + "<a href='https://code.csdn.net/snippets/"
                    + snippet_id
                    + "/fork' target='_blank' title='派生到我的代码片'  style='text-indent:0;'><img src='https://code.csdn.net/assets/ico_fork.svg' width=12 height=12 alt='派生到我的代码片' style='position:relative;top:2px;left:2px;'/></a>");
        }
        
        $("[code_snippet_id]").each(function () {
            __s_id = $(this).attr("code_snippet_id");
            if (__s_id != null && __s_id != "" && __s_id != 0 && parseInt(__s_id) > 70020) {
                __code_tool = __get_code_toolbar(__s_id);
                $(this).prev().find(".tools").append(__code_tool);
            }
        });
    });
</script>

    </div>
      <!--new top-->
    
    <script id="csdn-toolbar-id" btnId="header_notice_num" wrapId="note1" count="5" subCount="5" type="text/javascript" src="http://static.csdn.net/public/common/toolbar/js/toolbar.js"></script>     <!--new top-->
   
    <link href="http://csdnimg.cn/comm_ask/css/ask_float_block.css" type="text/css" rel="stylesheet" />
    <script language='JavaScript' type='text/javascript' src='http://csdnimg.cn/comm_ask/js/libs/wmd.js'></script>
    <script language='JavaScript' type='text/javascript' src='http://csdnimg.cn/comm_ask/js/libs/showdown.js'></script>
    <script language='JavaScript' type='text/javascript' src='http://csdnimg.cn/comm_ask/js/libs/prettify.js'></script>
    <script language='JavaScript' type='text/javascript' src='http://csdnimg.cn/comm_ask/js/apps/ask_float_block.js'></script>

</body>
</html>
